package kk.dao.impl;

import kk.dao.ManagerDao;
import kk.domain.Manager;
import kk.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class ManagerDaoImpl implements ManagerDao {
    private JdbcTemplate template=new JdbcTemplate(JDBCUtils.getDataSource());

    @Override
    public Manager findMangerByNameAndPassword(String name, String password) {
        String sql="select * from manager where manager_name = ? and manager_password = ?";
        try {
            Manager manager = template.queryForObject(sql, new BeanPropertyRowMapper<Manager>(Manager.class), name, password);
            return manager;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
